' //***************************************************************************
' // ***** Script Header *****
' //
' // Solution:  Solution Accelerator for Business Desktop Deployment
' // File:      ZeroTouchInstallation.vbs
' //
' // Purpose:   Start the Zero Touch deployment process
' //
' // Usage:     cscript ZeroTouchInstallation.vbs [/debug:true] 
' //
' // Microsoft Solution Version:  3.0.93
' // Microsoft Script Version:    3.0.93
' // Customer Build Version:      1.0.0
' // Customer Script Version:     1.0.0
' //
' // Microsoft History:
' // 3.0.7  MTN  03/27/2006  Created initial version
' // 3.0.93 MTN  10/25/2006  Fixed command line issues.
' //
' // Customer History:
' //
' // ***** End Header *****
' //***************************************************************************


'//----------------------------------------------------------------------------
'//
'//  Global constant and variable declarations
'//
'//----------------------------------------------------------------------------

Option Explicit

Dim oShell
Dim oFSO
Dim iRetVal
Dim sArgString, sArg
Dim sCmd
Dim sScriptDir
Dim oXML


'//----------------------------------------------------------------------------
'//  Initialization
'//----------------------------------------------------------------------------

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
For each sArg in WScript.Arguments
	sArgString = sArgString & sArg & " "
Next

sScriptDir = oFSO.GetParentFolderName(WScript.ScriptFullName)


'//----------------------------------------------------------------------------
'//  If we are in Windows PE, see if MSXML3 needs registered
'//----------------------------------------------------------------------------

On Error Resume Next
Set oXML = CreateObject("MSXML2.DOMDocument")
If Err then
	If oFSO.FileExists(sScriptDir & "\MSXML3.DLL") then
		sCmd = "regsvr32.exe /s """ & sScriptDir & "\MSXML3.DLL"""
		iRetVal = oShell.Run(sCmd, 0, true)
	End if
End if
On Error Goto 0


'//----------------------------------------------------------------------------
'//  Check to see if the prereq's have been satisfied
'//----------------------------------------------------------------------------

sCmd = "cscript.exe """ & sScriptDir & "\ZTIPrereq.vbs"""
iRetVal = oShell.Run(sCmd, 0, true)
If iRetVal <> 0 then
	WScript.Quit iRetVal
End if


'//----------------------------------------------------------------------------
'//  Launch ZeroTouchInstallation.wsf to do the heavy lifting
'//----------------------------------------------------------------------------

sCmd = "cscript.exe """ & sScriptDir & "\ZeroTouchInstallation.wsf"" " & sArgString
iRetVal = oShell.Run(sCmd, 0, true)


' All done

WScript.Quit iRetVal
